package com.club325.voicemicroblog.persist.test;

import com.club325.voicemicroblog.database.hibernateutil.HibernateUtil;
import com.club325.voicemicroblog.domain.User;

public class UserEnvironment implements Environment {
	private User u1,u2,u3,u4,admin1;
	protected User nu;
	protected static final String TestNewUserID = "NewUserID";
	protected static final String TestUserID1 = "TesrUserID1";
	protected static final String TestUserID2 = "TesrUserID2";
	protected static final String TestUserID3 = "TesrUserID3";
	protected static final String TestUserID4 = "TesrUserID4";
	protected static final String testAdminId1 = "TestAdminID1";
	protected static final String TestNewPassword = "12345678";
	protected static final String TestPassword1 = "12345678";
	protected static final String TestPassword2 = "22345678";
	protected static final String TestPassword3 = "32345678";
	protected static final String TestPassword4 = "42345678";
	protected static final int UserPemission = 0;
	protected static final int AdminPemission = 1;

	public UserEnvironment() {
		super();
		u1 = new User();
		u2 = new User();
		u3 = new User();
		u4 = new User();
		admin1 = new User();
		nu = new User();

		u1.setUserID(TestUserID1);
		u1.setPassword(TestPassword1);
		u1.setPermission(UserPemission);
		
		u2.setUserID(TestUserID2);
		u2.setPassword(TestPassword2);
		u2.setPermission(UserPemission);
		
		u3.setUserID(TestUserID3);
		u3.setPassword(TestPassword3);
		u3.setPermission(UserPemission);
		
		u4.setUserID(TestUserID4);
		u4.setPassword(TestPassword4);
		u4.setPermission(UserPemission);
		
		admin1.setUserID(testAdminId1);
		admin1.setPassword(TestNewPassword);
		admin1.setPermission(AdminPemission);
		
		nu.setUserID(TestNewUserID);
		nu.setPassword(TestNewPassword);
		nu.setPermission(UserPemission);
	}

	public void setup() {
		HibernateUtil.add(u1);
		HibernateUtil.add(u2);
		HibernateUtil.add(u3);
		HibernateUtil.add(u4);
		HibernateUtil.add(admin1);
	}

	public void tearDown() {
		HibernateUtil.delete(u1);
		HibernateUtil.delete(u2);
		HibernateUtil.delete(u3);
		HibernateUtil.delete(u4);
		HibernateUtil.delete(admin1);
	}
}
